package com.dwj.auto.comment.common.utils;

import com.dwj.auto.comment.model.dto.SessionContext;

/**
 * @ClassName SessionContextUtil
 * @Description 请求上下文工具
 * @Author dwjian
 * @Date 2019/9/24 17:20
 */
public class SessionContextUtil {

    public static final ThreadLocal<SessionContext> principal = new ThreadLocal<>();

    public static SessionContext getSessionContext(){
        if(SessionContextUtil.principal.get() == null){
            return new SessionContext();
        }
        return SessionContextUtil.principal.get();
    }

    public static void clean(){
        principal.remove();
    }

    public static void setSessionContext(SessionContext context){
        principal.set(context);
    }

}
